package com.zhuss.food.processor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.zhuss.bean.vo.food.product.DetailProductVo;
import com.zhuss.enums.UpperDownEnum;
import com.zhuss.exception.WpsException;


@Component("productCheck")
public class ProductCheck {
	
	@Autowired
	@Qualifier("productRead")
	private ProductRead productRead;
	
	public boolean checkCreateOrder(Long productId) throws WpsException {
		DetailProductVo product = ((DetailProductVo) productRead.detail(productId));
		if (UpperDownEnum.上架.sameKey(product.getStatus())) {
			return true;
		}
		return false;
	}

	
	public boolean checkUpper(Long productId) throws WpsException {
		DetailProductVo product = ((DetailProductVo) productRead.detail(productId));
		if (UpperDownEnum.下架.sameKey(product.getStatus()) || UpperDownEnum.未上架.sameKey(product.getStatus())) {
			return true;
		}
		return false;
	}
	
	public boolean checkDown(Long productId) throws WpsException {
		DetailProductVo product = ((DetailProductVo) productRead.detail(productId));
		if (UpperDownEnum.上架.sameKey(product.getStatus())) {
			return true;
		}
		return false;
	}

}
